﻿using Zack.Commons;

namespace WebCoreAPI.DDD
{
    public record User
    {
        public int Id { get; }//特征一
        public DateTime CreatedDateTime { get; init; }//特征一
        /// <summary>
        /// 中文名称，或英文名称
        /// </summary>
        public MultilingualString UserName { get; private set; }//特征一
        public int Credit { get; private set; }
        private string? passwordHash;//特征三
        public Geo Location{get;set;} //值对象
        private string? remark;
        public string? Remark
        { //特征四
            get { return remark; }
        }
        public string? Tag { get; set; }//特征五
        /// <summary>
        /// 季节，枚举类型
        /// </summary>
        public Season season{get;set;}
        private User()
        { //特征二
        }
        public User(string userName)
        {
            //特征二
            this.UserName = new MultilingualString(userName,String.Empty);
            this.CreatedDateTime = DateTime.Now;
            this.Credit = 10;
        }
        public void ChangeUserName(string newValue)
        {
            this.UserName = new MultilingualString(newValue,String.Empty);; 
        }
        public void ChangePassword(string newValue)
        {
            if (newValue.Length < 6) throw new ArgumentException("密码太短");

            this.passwordHash = newValue;
        }
    }
}
